<?php

namespace App\Models\service;

use App\Models\AdminModel;
use App\Models\CustomerModel;
use App\Models\OrderModel;
use App\Models\StaffModel;
use App\Models\TakeOrderModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class AbnormalModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_service_abnormal';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    const TYPE = [1 => '丢失', 2 => '破损', 3 => '湿货', 4 => '退件', 5=> '扣件', 6 => '其它'];

    const DEAL_TYPE = [1 => '退回', 2 => '销毁', 3 => '申请索赔', 4 => '提齐'];

    const SOURCE = [1 => '客户', 2 => '后台'];


    const STATUS = [1 => '待处理', 2 => '处理中', 3 => '处理完成'];

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];


    //订单
    public function order(): BelongsTo {
        return $this->belongsTo(OrderModel::class, 'order_id');
    }

    public function take_order(): BelongsTo {
        return $this->belongsTo(TakeOrderModel::class, 'take_order_id');
    }

    public function customer(): BelongsTo {
        return $this->belongsTo(CustomerModel::class, 'customer_id');
    }

    //处理方式
    public function mode(): BelongsTo {
        return $this->belongsTo(AbnormalModeModel::class, 'mode_id');
    }

}
